from importlib.resources import Package

from django.db import models
from user.models import Merchants
from datetime import datetime
# Create your models here.


# 菜品分类类型
# class Food(models.Model):
#     name = models.CharField(max_length=255, verbose_name='菜品的分类')
#
#     class Meta:
#         db_table = 'food'
#         verbose_name_plural = '菜品'
#
#     def __str__(self):
#         return self.name
#
#
# class Packages(models.Model):
#     name = models.CharField(max_length=255, verbose_name='套餐名字')
#
#     class Meta:
#         db_table = 'package'
#         verbose_name_plural = '套餐名字'
#
#     def __str__(self):
#         return self.name


# 商品分类
class Classification(models.Model):
    name = models.CharField(max_length=255, verbose_name='商品分类名')
    food = models.CharField(max_length=255, verbose_name='菜品名')
    package = models.CharField(max_length=255, verbose_name='套餐名')
    operating_time = models.DateTimeField(default=datetime.now(), verbose_name="登陆时间")
    mer = models.ForeignKey(Merchants,  on_delete=models.SET_NULL, blank=None, null=True, verbose_name='所属商家')

    class Meta:
        db_table = 'classification'
        verbose_name_plural = '商品分类'

    def __str__(self):
        return self.name


# 菜品表
class Table(models.Model):
    name = models.CharField(max_length=255, verbose_name='菜品/套餐名')
    price = models.DecimalField(max_digits=2, decimal_places=2, verbose_name='价格')
    introduce = models.CharField(max_length=255, verbose_name='介绍')
    description = models.CharField(max_length=255, verbose_name='详情描述')
    img = models.CharField(max_length=255, verbose_name='图片')
    sales = models.IntegerField(verbose_name="销量", default=0)
    classifica = models.ForeignKey(Classification, on_delete=models.SET_NULL, blank=None, null=True)

    class Meta:
        db_table = 'table'
        verbose_name_plural = '菜品'

    def __str__(self):
        return self.name




